<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1{
            background-color: rosybrown;
        }
        .box2{
            background-color: hotpink;
        }
        div{
            width: 100px;
            height: 100px;
        }

        .v-enter, .v-leave-to{
            opacity: 0;
        }
        .v-enter-to, .v-leave{
            opacity: 1;
        }
        .v-enter-active, .v-leave-active{
            transition: all 2s;
        }
    </style>
</head>
<body>
    

    <div id="app">
        <button @click="isShow = !isShow">点击</button>

        <transition>
            <div class="box1" v-if="isShow" key="box1">我是box1</div>
            <div class="box2" v-else key="box2">我是box2</div>
        </transition>
    </div>

    <script src="../lib/Vue/vue.js"></script>
    <script>

        var vm = new Vue({
            el: '#app',
            data: {
                isShow: true
            }
        })
    </script>
</body>
</html>